
Industry = {
		id: null, // 父行业id
		subId: null, // 子行业id
		
		/**
		 * 初始化
		 */
		init: function(id, subId) {
			this.id = id;
			this.subId = subId;
			this.listParent();
			
		},
		/**
		 * 加载父级行业
		 */
		listParent: function() {
			
			$.getJSON(baseURL+'industry/listParent/', function(data){
				var html = '<option value="">-请选择-</option>';
				  $.each(data.industries, function(key, item){
					  if(Industry.id == item.id) {
						  html += '<option selected value="' + item.id + '">' + item.intyName + '</option>';
					  } else {
						  html += '<option value="' + item.id + '">' + item.intyName + '</option>';
					  }
				  });
				  $('select[name="parentIndustry"]').html(html);
				  $('#parentIndustry').selectpicker('refresh');
				  if(Industry.id != null && Industry.id != '') {
					  Industry.listSub();
				  }
			});
		},
		/**
		 * 加载子级行业
		 */
		listSub: function() {
			
			var id = $('select[name="parentIndustry"]').val();
			$.getJSON(baseURL+'industry/listSub/'+id, function(data){
				  
				  var html = '<option value="">-请选择-</option>';
				  $.each(data.industries, function(key, item){
					  if(Industry.subId == item.id) {
						  html += '<option selected value="' + item.id + '">' + item.intyName + '</option>';
					  } else {
						  html += '<option value="' + item.id + '">' + item.intyName + '</option>';
					  }
					  
				  });
				  $('select[name="subIndustry"]').html(html);
				  $('#subIndustry').selectpicker('refresh');
			});
		}
		
}
/****** select事件监听 up ******/
$(function() {

	$("#parentIndustry").change(function(){
		
		if (this.selectedIndex > 0) {
			Industry.listSub();
		} else{
			$('select[name="subIndustry"]').html('<option value="">-请选择-</option>');
			$('#subIndustry').selectpicker('refresh');
		}
	});
});